package forexstreet;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class Main {
	public static void main(String[] args) throws MalformedURLException, IOException {
		Document doc = Jsoup.parse(new URL("http://www.fxstreet.com/analysis/forecast-currencies-poll/?pair=eurusd&time=2014-206#"), 10000);
		Elements e = doc.getElementsByClass("table-currenciesforecast");
		System.out.println(e.size());
		Element table = e.get(2).child(0).child(2);
		System.out.println(table);

		for (int i = 0; i < table.childNodeSize() / 2; i++) {
			if (!"tr-even".equals(table.child(i).className()) && !"tr-odd".equals(table.child(i).className())) {
				continue;
			}
			// System.out.println(table.child(i).className());
			String name = table.child(i).child(0).child(0).html();
			String oneWeekTarget = table.child(i).child(1).html();
			String oneMonthTarget = table.child(i).child(2).html();
			String oneQuoterTarget = table.child(i).child(3).html();
			String oneWeekTrend = table.child(i).child(4).html();
			String oneMonthTrend = table.child(i).child(5).html();
			String oneQuoterTrend = table.child(i).child(6).html();
			Suggestor s = new Suggestor(name, oneWeekTarget, oneMonthTarget, oneQuoterTarget, oneWeekTrend, oneMonthTrend, oneQuoterTrend);
			System.out.println(s);
		}
	}
}

class Suggestor {
	private String name;
	private String oneWeekTarget;
	private String oneMonthTarget;
	private String oneQuoterTarget;
	private String oneWeekTrend;
	private String oneMonthTrend;
	private String oneQuoterTrend;

	public Suggestor(String name, String oneWeekTarget, String oneMonthTarget, String oneQuoterTarget, String oneWeekTrend, String oneMonthTrend, String oneQuoterTrend) {
		this.name = name;
		this.oneWeekTarget = oneWeekTarget;
		this.oneMonthTarget = oneMonthTarget;
		this.oneQuoterTarget = oneQuoterTarget;
		this.oneWeekTrend = oneWeekTrend;
		this.oneMonthTrend = oneMonthTrend;
		this.oneQuoterTrend = oneQuoterTrend;
	}

	public String getName() {
		return name;
	}

	public String getOneWeekTarget() {
		return oneWeekTarget;
	}

	public String getOneMonthTarget() {
		return oneMonthTarget;
	}

	public String getOneQuoterTarget() {
		return oneQuoterTarget;
	}

	public String getOneWeekTrend() {
		return oneWeekTrend;
	}

	public String getOneMonthTrend() {
		return oneMonthTrend;
	}

	public String getOneQuoterTrend() {
		return oneQuoterTrend;
	}

	@Override
	public String toString() {
		return "suggestor [name=" + name + ", oneWeekTarget=" + oneWeekTarget + ", oneMonthTarget=" + oneMonthTarget + ", oneQuoterTarget=" + oneQuoterTarget + ", oneWeekTrend=" + oneWeekTrend + ", oneMonthTrend=" + oneMonthTrend + ", oneQuoterTrend=" + oneQuoterTrend + "]";
	}

}